home *** CD-ROM | disk | FTP | other *** search
- unit main;
- // This example program is very simple. Randomly select a number between 1
- // and 100, ask the user to guess it. Respond with high or low until the
- // user gets it right, then respond with confirmation and a count of how
- // many tries it took.
- // Most importantly, it shows one way to make the data persistent in the
- // disconnected environment of the user proxy mode.
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- htmler, StdCtrls;
-
- type
- TformMain = class(TForm)
- IAG_Region1: TIAG_Region;
- Label1: TLabel;
- lablResponse: TLabel;
- editGuess: TEdit;
- butnGuess: TIAG_Button;
- Variables: TIAG_Variables;
- intvMagicNo: TIntegerVar;
- intvGuessCount: TIntegerVar;
- Label2: TLabel;
- lablCount: TLabel;
- StringVar1: TStringVar;
- procedure butnGuessClick(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure IAG_Region1AfterShow(Sender: TObject);
- private
- public
- end;
-
- var
- formMain: TformMain;
-
- implementation
- {$R *.DFM}
-
- Uses
- //Required for access to the iagin object when designing forms which require
- // interaction beyond display and click on link capabilities
- IAG_Server_Info;
-
- procedure TformMain.butnGuessClick(Sender: TObject);
-
- // Buttons, DBNavigators, and Tabs cause a submit to occur. In Web terms, this
- // causes the browser to respond back to the server with the HTML variables and
- // through Portcullis, fires the appropriate click event. As a result, Buttons, Tabs,
- // and DBNavigators work as though you were just in the Delphi environment.
- // Other "click event" items are not currently supported as Click Events.
- // They are functional in every other way such that you can reference their
- // properties as usual. One exception to this is the 'disable' property which
- // would normally 'grey-out' a check box, is not currently supported. The
- // suggestion is to 'hide' it instead. In general, click events are not
- // supported as the environment is on the client machine (in the browser) until
- // one of the three supported events (above) occur, but most properties are supported.
-
- var
- iUserInput: Integer;
- begin
- butnGuess.Form := '';
- lablResponse.Visible := False;
-
- if intvMagicNo.value = -1 then intvMagicNo.value := Random(100) + 1;
-
- // Variables which are associated with EditBox's, radio buttons, check boxes
- // etc, are handled just as if you are still in the Delphi environment.
- // NO SPECIAL HANDLING REQUIRED.
-
- // Mesgbox is a procedure included with WSB which allows use of the mesgbox
- // procedure deployed on the web. The purpose of this is to allow creation
- // of a web page to deliver a message (like a modal dialog without the
- // buttons). The functionality of buttons can be implemented as links.
- // Use this in place of application.messagebox and/or showmessage
- // and/or messagedlg to deliver information.
- iUserInput := StrToIntDef(editGuess.Text, -1);
- if (iUserInput < 1) or (iUserInput > 100) then
- MesgBox('You entered an invalid number. Please go back and try again.', '', '', '')
- else if intvMagicNo.value = iUserInput then
- MesgBox('You guessed it! It took you ' + intvGuessCount.AsString + ' guesses.'
- , 'Play another game', iagin.URLToForm('Main', '',''), '')
- else begin
- lablCount.Caption := IntToStr(StrToIntDef(lablCount.Caption, 0) + 1);
- butnGuess.Form := 'Self';
- if iUserInput < intvMagicNo.value then lablResponse.Caption := IntToStr(iUserInput) + ' is too low.'
- else lablResponse.Caption := IntToStr(iUserInput) + ' is too high.';
- lablResponse.Visible := True;
- end;
- end;
-
- procedure TformMain.FormCreate(Sender: TObject);
- begin
- Randomize;
- end;
-
- procedure TformMain.IAG_Region1AfterShow(Sender: TObject);
- begin
- lablResponse.Caption := '';
- end;
-
- end.
-